package com.liveinstars.im.entity;

import com.baomidou.mybatisplus.annotation.TableField;
import com.liveinstars.im.common.BaseEntity;
import lombok.Data;
import lombok.ToString;

/**
 * <p>
 * 
 * </p>
 *
 * @author 8btc
 * @since 2019-02-01
 */
@Data
@ToString
public class ChatMessage extends BaseEntity {

    /**
     * 发送消息
     */
    public final static int TYPE_SEND = 0;
    /**
     * 接收消息
     */
    public final static int TYPE_RECEIVE = 1;

    public final static int MSG_TYPE_UU = 0;// 人人之间的消息
    public final static int MSG_TYPE_UCG = 1;// 群消息
    public final static int MSG_TYPE_UDG = 2;// 讨论组消息

    public final static int CONTENT_TYPE_NORMAL = 0;// 普通消息
    public final static int CONTENT_TYPE_ATTACHMENT = 1;// 为带附件消息
    public final static int CONTENT_TYPE_NOTIFY = 2;// 为通知消息
    public final static int CONTENT_TYPE_JUMP = 4;//跳转消息
    public final static int CONTENT_TYPE_CANDY = 5;//红包消息

    public final static int STATUS_UNKNOWN = 0;// 未知状态，在服务端不会出现，在客户端会出现
    public final static int STATUS_SEND = 1;// 默认状态已发送
    public final static int STATUS_RECEIVED = 2;// 已收到
    public final static int STATUS_READ = 3;// 已阅读
    public final static int STATUS_FAIL_FRIEND_SHIELD = 4;// 发送失败，好友被屏蔽
    public final static int STATUS_FAIL_TEMP_SHIELD = 5;// 发送失败，临时关系被屏蔽
    public final static int STATUS_FAIL_NOT_MEMBER = 6;// 发送失败，不是圈子成员
    public final static int STATUS_WITHDRAW = 7;// 撤回
    public final static int STATUS_FAIL_BESHIELD = 8;// 发送失败，被禁言
    public final static int STATUS_FAIL_CHAT_GROUP_DISBAND = 9; //发送消息失败，群被解散了
    public final static int STATUS_FAIL_MESSAGE = 10; //消息发送失败
    public final static int STATUS_RATE_LIMIT_MESSAGE = 11; //消息发送频率过快
    public final static int STATUS_CLOSE_MESSAGE = 12; //消息服务停用


    public static final int TYPE_UNKNOWN = 0;// 未知文件类型
    public static final int TYPE_JPG = 1;
    public static final int TYPE_PNG = 2;
    public static final int TYPE_GIF = 3;
    public static final int TYPE_DOC = 4;
    public static final int TYPE_DOCX = 5;
    public static final int TYPE_PPT = 6;
    public static final int TYPE_PPTX = 7;
    public static final int TYPE_XLS = 8;
    public static final int TYPE_XLSX = 9;
    public static final int TYPE_PDF = 10;
    public static final int TYPE_TXT = 11;
    public static final int TYPE_RAR = 12;
    public static final int TYPE_ZIP = 13;
    public static final int TYPE_BMP = 14;


    public static final int TYPE_VOICE = 101;// 语音
    public static final int TYPE_VIDEO = 102;// 视频
    /**
     * 非持久化字段
     */
//    @Transient
    private String token = "";

    // 是否需要转发，如果传入的是clinet则需要转发，如果是服务端则说明本就是转发消息不需要转发
    private boolean transfer;

    private static final long serialVersionUID = 1L;

    private Long id = 0L;

    private Long fromId = 0L;

    private String uuid;

    private Integer status;

    private Long toId = 0L;

    private String content = "";

    private Integer contentType;//普通或者附件或者通知

    private String fileName = "";//附件名称

    private String path = "";//附件地址

    private Integer fileType = 0;//附件类型

    private Integer date = 0;

    private Integer type = 0;//send or receive

    private Integer msgType = 0;//人人

    private Long chatGroupId = 0L;

    @TableField(exist = false)
    private String userName = "";

    @TableField(exist = false)
    private String userAvator = "";

    @TableField(exist = false)
    private Integer userGroupId = 9;

    //图片或附件的参数，如果长宽
    private String fileParam = "";

    public ChatMessage(){
        super();
    }

    public ChatMessage(Long fromId, Long toId, String uuid, int status, int msgType
            , String content, boolean transfer, Integer date, Integer contentType, Long chatGroupId) {
        super();
        this.fromId = fromId;
        this.toId = toId;
        this.uuid = uuid;
        this.status = status;
        this.msgType = msgType;
        this.content = content;
        this.transfer = transfer;
        this.date = date;
        this.contentType = contentType;
        this.chatGroupId = chatGroupId;

    }

    public ChatMessage(String token, boolean transfer, Long id, Long fromId,
                       String uuid, Integer status, Long toId, String content,
                       Integer contentType, String fileName, String path, Integer fileType,
                       Integer date, Integer type, Integer msgType, Long chatGroupId,
                       String userName, String userAvator, Integer userGroupId, String fileParam) {
        super();
        this.token = token;
        this.transfer = transfer;
        this.id = id;
        this.fromId = fromId;
        this.uuid = uuid;
        this.status = status;
        this.toId = toId;
        this.content = content;
        this.contentType = contentType;
        this.fileName = fileName;
        this.path = path;
        this.fileType = fileType;
        this.date = date;
        this.type = type;
        this.msgType = msgType;
        this.chatGroupId = chatGroupId;
        this.userName = userName;
        this.userAvator = userAvator;
        this.userGroupId = userGroupId;
        this.fileParam = fileParam;
    }
}
